package com.example.lenovo.weiyi;

import android.Manifest;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AlertDialog;
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;

import com.com.ruanmeng.demon.SYM;
import com.com.ruanmeng.demon.VersionM;
import com.com.ruanmeng.utils.Params;
import com.com.ruanmeng.utils.PreferencesUtils;
import com.com.ruanmeng.utils.UpdateService;
import com.com.ruanmeng.view.NestRadioGroup;
import com.com.ruanmeng.view.PopupWindowUpdateUtils;
import com.ruanmeng.fragment.KangFuFragment;
import com.ruanmeng.fragment.MineFragment;
import com.ruanmeng.fragment.ServiceFragment;
import com.ruanmeng.fragment.ShouYeFragment;
import com.yolanda.nohttp.NoHttp;
import com.yolanda.nohttp.rest.Request;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Timer;
import java.util.TimerTask;

import butterknife.BindView;
import butterknife.ButterKnife;
import nohttp.CallServer;
import nohttp.CustomHttpListener;
import share.Const;
import share.HttpIP;

import static com.example.lenovo.weiyi.R.id.rb_zd;

public class MainActivity extends BaseActivity implements
        NestRadioGroup.OnCheckedChangeListener {

    @BindView(R.id.fragment_container)
    FrameLayout fragmentContainer;
    @BindView(R.id.rb_sy)
    RadioButton rbSy;
    @BindView(rb_zd)
    RadioButton rbZd;
    @BindView(R.id.rb_wode)
    RadioButton rbWode;
    @BindView(R.id.rg_main_check)
    NestRadioGroup rgMainCheck;
    @BindView(R.id.view_main_line)
    View viewMainLine;
    private FragmentTransaction transaction;
    private Fragment fragement;
    private ShouYeFragment shouyefragment;
    private KangFuFragment orderedfragment;
    private MineFragment minefragment;
    private ImageView imv_home;
    private SYM model;
    private VersionM modelver;
    private ServiceFragment servicefragment;
    private boolean isForce = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        AddMianActivity(this);
        checkReadPermission();
        init();
//        getData();
        if (Params.getversion == 0) {
            Params.getversion = 1;
            getVersionData();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (Params.ToSy == 1) {
            Params.ToSy = 0;
            rbZd.performClick();
        }
    }

    public void init() {
        rgMainCheck.setOnCheckedChangeListener(this);
        rbZd.performClick();
        //右上角
        imv_home = (ImageView) findViewById(R.id.imv_home);
    }

    public void doClick(View v) {
        Intent in;
        switch (v.getId()) {
            case R.id.li_sy_kfpd://健康档案
                in = new Intent(MainActivity.this, KangFuPingDingListActivity.class);
                startActivity(in);
                break;
            case R.id.li_sy_jcbg://检测报告
                in = new Intent(MainActivity.this, JianCeReportListActivity.class);
                startActivity(in);
                break;
            case R.id.li_sy_qcard://二维码
                in = new Intent(MainActivity.this, MyErWeiMaActivity.class);
                startActivity(in);
                break;
            case R.id.li_kfzd_start://开始运动
                //获取当前时间
//                SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//                String date = sDateFormat.format(new java.util.Date());
//                CommonUtil.showToask(MainActivity.this,"date===="+date);
                in = new Intent(MainActivity.this, TrainListActivity.class);
                startActivity(in);
                break;
            case R.id.li_kfzd_video://视频
                in = new Intent(MainActivity.this, VideoListActivity.class);
                startActivity(in);
                break;
            case R.id.li_kfzd_music://音乐--修改为服务
                in = new Intent(MainActivity.this, NewPayServiceActivity.class);
                startActivity(in);
                break;
            case R.id.li_kfzd_zixun://咨询
                in = new Intent(MainActivity.this, ZiXunActivity.class);
                startActivity(in);
                break;
            case R.id.li_sy_jkzs://健康知识
                in = new Intent(MainActivity.this, HealthMessListActivity.class);
                startActivity(in);
                break;
            case R.id.imv_home://进公告列表
//                imv_home.setBackgroundResource(R.drawable.home_xx);
//                in = new Intent(MainActivity.this, NotoceListActivity.class);
//                startActivity(in);
                in = new Intent(MainActivity.this, ZiXunActivity.class);
                startActivity(in);
                break;
            case R.id.li_kfzd_service://定制服务
                in = new Intent(MainActivity.this, DZServiceActivity.class);
                startActivity(in);
                break;

        }
    }

    @Override
    public void onCheckedChanged(NestRadioGroup group, int checkedId) {
        transaction = getSupportFragmentManager().beginTransaction();
        if (fragement != null)
            transaction.hide(fragement);
        HiddenLayBack();
        switch (checkedId) {
            case R.id.rb_sy:
                ShowLayMess();
                ChangLayTitle("首页");
                findViewById(R.id.lay_sy).setVisibility(View.VISIBLE);
//                if (null == shouyefragment) {
                shouyefragment = ShouYeFragment.instantiation();
                transaction.add(R.id.fragment_container, shouyefragment);
//                }
                fragement = shouyefragment;
                transaction.show(shouyefragment);
                getData();
                break;
            case rb_zd:
                HiddenLayMess();
               /* if (PreferencesUtils.getInt(MainActivity.this, "Login") != 1) {
                    Intent in = new Intent(MainActivity.this, LoginActivity.class);
                    startActivity(in);
                    rbSy.performClick();
                    return;
                }*/
                ChangLayTitle("康复指导");
                findViewById(R.id.lay_sy).setVisibility(View.VISIBLE);
                if (null == orderedfragment) {
                    orderedfragment = new KangFuFragment();
                    transaction.add(R.id.fragment_container, orderedfragment);
                }
                fragement = orderedfragment;
                transaction.show(orderedfragment);
                break;
            case R.id.rb_service://定制服务
                HiddenLayMess();
               /* if (PreferencesUtils.getInt(MainActivity.this, "Login") != 1) {
                    Intent in = new Intent(MainActivity.this, LoginActivity.class);
                    startActivity(in);
                    rbSy.performClick();
                    return;
                }*/
                ChangLayTitle("定制服务");
                findViewById(R.id.lay_sy).setVisibility(View.VISIBLE);
                if (null == minefragment) {
                    servicefragment = new ServiceFragment();
                    transaction.add(R.id.fragment_container, servicefragment);
                }
                fragement = servicefragment;
                transaction.show(servicefragment);
                break;
            case R.id.rb_wode:
                HiddenLayMess();
               /* if (PreferencesUtils.getInt(MainActivity.this, "Login") != 1) {
                    Intent in = new Intent(MainActivity.this, LoginActivity.class);
                    startActivity(in);
                    rbSy.performClick();
                    return;
                }*/
                findViewById(R.id.lay_sy).setVisibility(View.GONE);
                if (null == minefragment) {
                    minefragment = new MineFragment();
                    transaction.add(R.id.fragment_container, minefragment);
                }
                fragement = minefragment;
                transaction.show(minefragment);
                break;
        }
        transaction.commit();
    }

    /**
     * 重写返回键事件,双击退出程序
     */
    private static Boolean isExit = false;

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            exitBy2Click(); // 调用双击退出函数
        }
        return false;
    }

    private void exitBy2Click() {
        Timer tExit = null;
        if (isExit == false) {
            isExit = true; // 准备退出
            Toast.makeText(this, "再按一次退出程序", Toast.LENGTH_SHORT).show();
            tExit = new Timer();
            tExit.schedule(new TimerTask() {
                @Override
                public void run() {
                    isExit = false; // 取消退出
                }
            }, 2000); // 如果2秒钟内没有按下返回键，则启动定时器取消掉刚才执行的任务
        } else {
            clearActivity();
            finish();
            System.exit(0);
        }
    }

    /**
     * 是否签到
     */
    /*private void getData() {
        Request<String> mRequest = NoHttp.createStringRequest(HttpIP.PerMess, Const.POST);
        mRequest.addHeader("token", PreferencesUtils.getString(MainActivity.this, "uid"));
        CallServer.getRequestInstance().add(MainActivity.this, 0, mRequest,
                new CustomHttpListener(MainActivity.this, true, PerMessM.class) {
                    @Override
                    public void doWork(Object data, boolean isOne) {
                        PerMessM model = ((PerMessM) data);
//                        PreferencesUtils.putString(MainActivity.this, "IsQD", model.getObject().getIsSign());
                    }

                    @Override
                    public void onFinally(JSONObject obj) throws JSONException {
                        super.onFinally(obj);
                    }
                }, true, true);
    }
*/

    /**
     * 获取右上角消息图片是否带小红点
     */
    private void getData() {
        Request<String> mRequest = NoHttp.createStringRequest(HttpIP.SY, Const.POST);
        mRequest.addHeader("token", PreferencesUtils.getString(MainActivity.this, "uid"));
        CallServer.getRequestInstance().add(MainActivity.this, 0, mRequest,
                new CustomHttpListener(MainActivity.this, true, SYM.class) {

                    @Override
                    public void doWork(Object data, boolean isOne) {
                        model = ((SYM) data);
                        SYM.ObjectBean.NoticeBean noticeBean = model.getObject().getNotice();
                        //关于弹出消息
                        if (noticeBean != null) {
                            if (TextUtils.isEmpty(PreferencesUtils.getString(MainActivity.this, "notice_date"))) {//第一次弹出
//                                imv_home.setBackgroundResource(R.drawable.home_xx_pre);
                                ShowPop();
                            } else if (!noticeBean.getCreateDate().equals(PreferencesUtils.getString(MainActivity.this, "notice_date"))) {
//                                imv_home.setBackgroundResource(R.drawable.home_xx_pre);
                                ShowPop();
                            } else {
//                                imv_home.setBackgroundResource(R.drawable.home_xx);
                            }
                            PreferencesUtils.putString(MainActivity.this, "notice_date", noticeBean.getCreateDate());
                        }
                    }

                    @Override
                    public void onFinally(JSONObject obj) throws JSONException {
                        super.onFinally(obj);
                    }
                }, true, false);
    }

    /**
     */
    public void ShowPop() {
        // 加载布局
        LayoutInflater inflater = LayoutInflater
                .from(MainActivity.this);
        View view = inflater.inflate(R.layout.pop_notice, null);
        TextView tv_notice_title = (TextView) view.findViewById(R.id.tv_notice_title);
        TextView tv_notice_content = (TextView) view.findViewById(R.id.tv_notice_content);
        TextView tv_notice_cancel = (TextView) view.findViewById(R.id.tv_notice_cancel);
        TextView tv_see = (TextView) view.findViewById(R.id.tv_see);
        tv_notice_content.setMovementMethod(LinkMovementMethod.getInstance());
        tv_notice_content.setText(Html.fromHtml(model.getObject().getNotice().getContent()).toString().trim());
        tv_notice_title.setText(model.getObject().getNotice().getTitle());
        // 创建popupwindow对话框
        final PopupWindow pop = new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        pop.setFocusable(true);// 必须有，因为要获得焦点进行输入
        // 设置此参数，点击外边可消失
        pop.setBackgroundDrawable(new BitmapDrawable());
        // 点击其他除了popupwindow对话框的地方就可使popupwindow对话框消失
        pop.setOutsideTouchable(true);
        //pop.showAtLocation(liFr, Gravity.CENTER, 0, 0);// 显示位置以某控件为中心
        if (Build.VERSION.SDK_INT >= 24) {
            int[] a = new int[2];
            viewMainLine.getLocationInWindow(a);
            pop.showAtLocation((MainActivity.this).getWindow().getDecorView(), Gravity.NO_GRAVITY, 0, a[1] + viewMainLine.getHeight());
        } else {
            pop.showAsDropDown(viewMainLine);
        }
        tv_notice_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                pop.dismiss();
            }
        });
        tv_see.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                pop.dismiss();
                imv_home.setBackgroundResource(R.drawable.home_xx);
                Intent in = new Intent(MainActivity.this, NoticeXQActivity.class);
                in.putExtra("title", model.getObject().getNotice().getTitle());
                in.putExtra("content", model.getObject().getNotice().getContent());
                in.putExtra("time", model.getObject().getNotice().getCreateDate());
                startActivity(in);
                imv_home.setBackgroundResource(R.drawable.home_xx);
            }
        });
    }

    public void getVersionData() {
        Request<String> mRequest = NoHttp.createStringRequest(HttpIP.UpdateVersion, Const.POST);
        // 添加到请求队列
        CallServer.getRequestInstance().add(MainActivity.this, 0, mRequest,
                new CustomHttpListener(MainActivity.this, true, VersionM.class) {
                    @Override
                    public void doWork(Object data, boolean isOne) {
                        modelver = ((VersionM) data);
                        if (getVersionName(MainActivity.this).equals(modelver.getObject().getVersionNo())) {
//                            CommonUtil.showToask(MainActivity.this, "当前已是最新版本");
                        } else {
                            if (!TextUtils.isEmpty(modelver.getObject().getForce())) {
                                String a = modelver.getObject().getForce();
                                if (a.equals("1")) {//强制
                                    isForce = true;
                                    PopupWindowUpdateUtils.getInstance().getSmartUpdateDialog(MainActivity.this, modelver.getObject().getContent(), modelver.getObject().getTitle(), new PopupWindowUpdateUtils.PopupYearWindowCallBack() {
                                        @Override
                                        public void doWork() {
                                            downLoadApk(modelver.getObject().getUrl());
                                        }

                                        @Override
                                        public void doBack() {

                                        }
                                    });
                                } else {//非强制
                                    isForce = false;
                                    showData(modelver, true);
                                }
                            } else {//非强制
                                isForce = false;
                                showData(modelver, true);
                            }
//                            Version();
                        }
                    }

                    @Override
                    public void onFinally(JSONObject obj) throws JSONException {
                        super.onFinally(obj);
                    }
                }, true, false);
    }

    /**
     * 版本名
     */
    public static String getVersionName(Context context) {
        return getPackageInfo(context).versionName;
    }

    private static PackageInfo getPackageInfo(Context context) {
        PackageInfo pi = null;

        try {
            PackageManager pm = context.getPackageManager();
            pi = pm.getPackageInfo(context.getPackageName(),
                    PackageManager.GET_CONFIGURATIONS);

            return pi;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return pi;
    }

    /**
     * 版本更新
     */
    public void Version() {
        // 解析xml
        View view = View.inflate(MainActivity.this,
                R.layout.setting_custom_dialog, null);
        TextView text_dialog = (TextView) view.findViewById(R.id.text_dialog);
        text_dialog.setText("检测到新版本，是否更新？");
        // 对话框
        final Dialog dialog = new AlertDialog.Builder(MainActivity.this)
                .create();
        dialog.show();
        dialog.getWindow().

                setContentView(view);

        // 取消按钮
        TextView btn_Cancel = (TextView) view.findViewById(R.id.cancle);
        btn_Cancel.setOnClickListener(new View.OnClickListener() {
                                          @Override
                                          public void onClick(View v) {
                                              dialog.dismiss();
                                          }
                                      }

        );
        // 确定按钮
        TextView btn_OK = (TextView) view.findViewById(R.id.sure);
        btn_OK.setOnClickListener(new View.OnClickListener() {
                                      @Override
                                      public void onClick(View v) {
                                          dialog.dismiss();
                                          Intent intent1 = new Intent();
                                          intent1.setClass(MainActivity.this, UpdateService.class);
                                          intent1.putExtra("versionCode", modelver.getObject().getVersionNo());
                                          intent1.putExtra("url", modelver.getObject().getUrl());
                                          MainActivity.this.startService(intent1);
                                      }
                                  }

        );


    }

    /*
       * 从服务器中下载APK
       */
    Handler handler_Delay = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case 1:
                    getVersionData();
                    break;
            }
        }
    };

    protected void downLoadApk(final String path) {
        final ProgressDialog pd;    //进度条对话框
        pd = new ProgressDialog(MainActivity.this);
        pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        pd.setCanceledOnTouchOutside(false);
        pd.setOnKeyListener(new DialogInterface.OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialogInterface, int keycode, KeyEvent keyEvent) {
                if ((keycode == KeyEvent.KEYCODE_BACK)) {
                    return true;
                } else {
                    return false;
                }
            }
        });
        pd.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialogInterface) {
                if (isForce) {
                    handler_Delay.sendEmptyMessageDelayed(1, 2000);
                }
            }
        });
        pd.setMessage("正在下载更新...");
        pd.show();
        new Thread() {
            @Override
            public void run() {
                try {
                    File file = getFileFromServer(path, pd);
                    sleep(3000);
                    installApk(file);
                    pd.dismiss(); //结束掉进度条对话框
                    isLoad = false;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }


    private boolean isExistSd() {
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            return true;
        } else
            return false;
    }

    private boolean isLoad = false;

    /*
  * 从服务器下载apk
  */
    public File getFileFromServer(String path, ProgressDialog pd) throws Exception {
        //如果相等的话表示当前的sdcard挂载在手机上并且是可用的
        if (isExistSd()) {
            URL url = new URL(path);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            long fileLength = conn.getContentLength();
            conn.setConnectTimeout(5000);
            //获取到文件的大小
//            pd.setMax(conn.getContentLength());
            InputStream is = conn.getInputStream();
            File file = new File(Environment.getExternalStorageDirectory(), "working.apk");// Environment.getExternalStorageDirectory().getAbsolutePath()
            if (!file.getParentFile().exists()) {
                // 分两次mkdirs，是为了避免目录层级过高导致目录创建失败的情况
                file.getParentFile().mkdirs();
            }
            if (!file.exists()) {
                file.createNewFile();
            }
            FileOutputStream fos = new FileOutputStream(file);
            BufferedInputStream bis = new BufferedInputStream(is);
            byte[] buffer = new byte[1024];
            int len;
            int total = 0;
            while ((len = bis.read(buffer)) != -1) {
                fos.write(buffer, 0, len);
                total += len;
                //获取当前下载量
                int curProgress = (int) (((float) total / fileLength) * 100);
                pd.setProgress(curProgress);
            }
            fos.close();
            bis.close();
            is.close();
            return file;
        } else {
            return null;
        }
    }

    //安装apk
    protected void installApk(File file) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        // 执行的数据类型
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
            intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
            startActivity(intent);
        } else {//7.0
//            Uri apkUri =
//                    FileProvider.getUriForFile(this, "com.ruanmeng.daddywashing_delivery.fileprovider", file);
//            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
//            intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
//            Uri apkUri =
//                    FileProvider.getUriForFile(this, "com.ruanmeng.weiyi.provider", file);
//            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
//            intent.setDataAndType(apkUri, "applicationnd.android.package-archive");
            Uri apkUri = FileProvider.getUriForFile(this, "com.ruanmeng.weiyi.provider", file);//在AndroidManifest中的android:authorities值
            Intent install = new Intent(Intent.ACTION_VIEW);
            install.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setClassName("com.android.packageinstaller", "com.android.packageinstaller.PackageInstallerActivity");
            install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);//添加这一句表示对目标应用临时授权该Uri所代表的文件
            install.setDataAndType(apkUri, "application/vnd.android.package-archive");
            startActivity(install);
        }

    }

    /**
     * 更新版本
     *
     * @param dataM
     */
    private void showData(final VersionM dataM, boolean isUp) {
        try {
            PopupWindowUpdateUtils.getInstance().getUpdateDialog(this, new PopupWindowUpdateUtils.PopupYearWindowCallBack() {
                @Override
                public void doWork() {
                    downLoadApk(dataM.getObject().getUrl());
                }

                @Override
                public void doBack() {

                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //关于系统6.0以上的权限适配注意Manifest的导包  读写权限
    private void checkReadPermission() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
            if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
                // 是否需要弹出一个解释申请该权限的提示给用户，如果为true，则可以弹。
                if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_EXTERNAL_STORAGE)) {
                    Toast.makeText(MainActivity.this, "没权限", Toast.LENGTH_SHORT).show();
                    ActivityCompat.requestPermissions(
                            MainActivity.this,
                            new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
                            0);
                } else {

                    // 在Fragment中申请权限，不要使用ActivityCompat.requestPermissions,
                    // 直接使用Fragment的requestPermissions方法，否则会回调到Activity的 onRequestPermissionsResult
                    ActivityCompat.requestPermissions(
                            MainActivity.this,
                            new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
                                    Manifest.permission.WRITE_EXTERNAL_STORAGE},
                            0);

                    // Const.LOCATION_REQUEST is an app-defined int constant.
                    // The callback method gets the result of the request.
                }

            }
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        switch (requestCode) {
            case 0: {
                if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                } else {
                    Toast.makeText(this, "请求权限被拒绝，请重新开启权限", Toast.LENGTH_LONG).show();
                }
            }
        }
    }
}
